package com.unytech.project.entity.security;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Index;

import com.unytech.project.entity.BaseEntity;
import com.unytech.project.entity.system.User;

/**
 * 操作记录类
 * @author DolphinBoy
 *
 */
@Entity
@Table(name="T_OPERATERECORD")
@GenericGenerator(name="uuidpk",strategy="uuid")
public class OperateRecord extends BaseEntity {	
	@Id @GeneratedValue(generator="uuidpk")
	@Column(length=32)
	@Index(name="recordid_index")
	private String recordid; 
	 
	/** 操作URI */
	@Column(length=60)
	private String recorduri;                
	
	/** 操作模块 */
	@Column(length=30)
	private String recordmodule;             
	
	/** 操作链  */
	@Column(length=50)
	private String operatechain;
	
	/** 最终动作  */
	@Column(length=20)
	private String operateaction;
	
	/** 操作开始时间  */
	@Temporal(TemporalType.TIMESTAMP) 
	private Date starttime = new Date();      
	
	/** 操作结束时间  */
	@Temporal(TemporalType.TIMESTAMP) 
	private Date endtime; 
	
	/** 耗时 */
	private Integer elapsedtime;

	/** 错误记录 */
	@OneToOne(cascade={CascadeType.REFRESH,CascadeType.REMOVE}, mappedBy="operaterecord", optional=true)
	private ErrorRecord errorrecord;    
	
	/** 操作人 */
	@ManyToOne(cascade={CascadeType.REFRESH}, optional=true)
	@JoinColumn(name="recorduser_id")
	private User recorduser;

	public String getRecordid() {
		return recordid;
	}

	public void setRecordid(String recordid) {
		this.recordid = recordid;
	}

	public String getRecorduri() {
		return recorduri;
	}

	public void setRecorduri(String recorduri) {
		this.recorduri = recorduri;
	}

	public String getRecordmodule() {
		return recordmodule;
	}

	public void setRecordmodule(String recordmodule) {
		this.recordmodule = recordmodule;
	}
	
	public Date getStarttime() {
		return starttime;
	}

	public void setStarttime(Date starttime) {
		this.starttime = starttime;
	}

	public Date getEndtime() {
		return endtime;
	}

	public void setEndtime(Date endtime) {
		this.endtime = endtime;
	}

	public ErrorRecord getErrorrecord() {
		return errorrecord;
	}

	public void setErrorrecord(ErrorRecord errorrecord) {
		this.errorrecord = errorrecord;
	}

	public User getRecorduser() {
		return recorduser;
	}

	public void setRecorduser(User recorduser) {
		this.recorduser = recorduser;
	}

	public Integer getElapsedtime() {
		return elapsedtime;
	}

	public void setElapsedtime(Integer elapsedtime) {
		this.elapsedtime = elapsedtime;
	}

	public String getOperatechain() {
		return operatechain;
	}

	public void setOperatechain(String operatechain) {
		this.operatechain = operatechain;
	}

	public String getOperateaction() {
		return operateaction;
	}

	public void setOperateaction(String operateaction) {
		this.operateaction = operateaction;
	}
}
